<#include
        "../common/com.html"  /> <@layout>
<head>
    <!-- page specific plugin styles -->
    <link rel="stylesheet" href="${ctx}/static/assets/css/ui.jqgrid.css" />
    <!-- ace styles -->
</head>
    <script type="text/javascript">
    

  /**
     * 删除选中的模型信息
     */
    function dels(obj,yxbz){
            var url = '${ctx}/hyglJfjl/delete/';
            $("#id").attr("value",obj);
            $('#myform').form('submit', {
                url : url,
                onSubmit : function() {
                },
                success : function(data) {
                    // 回填页面
                    alert(data);
                    window.location.reload();
                }
            });
    }

</script>
<body>

<div class="page-content">
	<div class="page-header" style="height: 15px">
    </div><!-- /.page-header -->
    
	 <div class="row-fluid">
        <div class="span12">
           <table class="table  table-striped table-condensed table-bordered">
				<thead>
					<tr class="info">
						<th><i class="icon-caret-right blue"></i> 卡号</th>


						<th>姓名</th>
						<th>余额</th>
						<th>积分</th>
						<th class="hidden-phone">电话</th>

						<th>车牌号码</th>

						<th class="hidden-phone">车型</th>
						<th class="hidden-phone">车款</th>

						<th>保险日期</th>
						<th>年检日期</th>
					</tr>
				</thead>
				<#list newlist as m>
				<tbody>
					<tr class="info">
						<td>
					<input id="ye" name="ye" type="hidden" style="min-height: 24px;" value="${(m.ye)!}" />
					<input id="jf" name="jf" type="hidden" style="min-height: 24px;" value="${(m.vipcard)?number+(m.moneys)?number}" />
						${(m.card)!}</td>
						<td >
						${(m.yhm)!}</td>
						<td>
						${(m.ysje)?number+(m.czje)?number-(m.vipcard)?number}   </td>
							<td>
						${(m.vipcard)?number+(m.moneys)?number-(m.xfjfs)?number}   </td>
						<td class="hidden-phone">${(m.dh)!}</td>

						<td>${(m.cph)!}</td>

						<td class="hidden-phone">${(m.cx)!}</td>
						<td class="hidden-phone">${(m.ck)!}</td>

						<td>${(m.bxrq)!}</td>
						<td>${(m.njrq)!}</td>
					</tr>
				</tbody>
				</#list>
			</table>
            <!-- PAGE CONTENT BEGINS -->
            <table id="grid-table"></table>
            <div id="grid-pager"></div>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.span -->
    </div><!-- /.row-fluid -->
</div><!-- /.page-content -->
<!-- page specific plugin scripts -->
<form id="myform"  method="post">
<input id="card" name="card" type="hidden" style="min-height: 24px;" value="${(card)!}" />
<input id="id" name="id" type="hidden" style="min-height: 24px;" value="" />
</form>

<#include  "../common/end.html"  /> 
<script>
var hujf=0;
var xyjf=0;
var jf=$("#jf").val();
    function add(){
    	var id=$('#grid-table').jqGrid('getGridParam','selarrrow');
    	if(id.length==0){
    		alert("请选择一条需用兑换奖励！");
    		return;
    	}
    	for(var i=0;i<id.length;i++){
    		var rowData =$('#grid-table').jqGrid('getRowData',id[i]);
    		xyjf=  Number(xyjf) +Number(rowData.xfjf  ) ;
    	}

    	if(Number(jf) <Number(xyjf)  ){
    		alert("积分不够无法兑换！");
    		xyjf=0;
    		return;
    	} else {
    		xyjf=0;
    		$("#id").val(id);
    		 var	 url = '${ctx}/xskd/jfdhupdate';
    		 $('#myform').form('submit', {
                 url : url,
                 onSubmit : function() {
                 },
                 success : function(data) {
                		var obj = eval("("+data+")");  ;
        				var data =obj.id;
        				var msg =obj.message;
        				if(data=="0"){
        					alert(msg);
        				} else {
        					alert(msg);
        					window.location.href = ' ${ctx}/xskd?card='+data;
        				}
                 }
             });
    	}
    }
</script>
<script type="text/javascript">

$("#search_btn").click(function(){
	var date="${(date)!}"; 
   // var start=$("#start").val();

    $("#grid-table").jqGrid('setGridParam',{
        datatype:'json',
        postData:{  'search_GTE_start':date,'search_LTE_end':date}, //发送数据 'search_LIKE_lrrq':start
        page:1
    }).trigger("reloadGrid"); //重新载入
});


jQuery(function($) {

    //  jqgrid
    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";
	var date="${(date)!}"; 


    jQuery(grid_selector).jqGrid({
        datatype: "json", //将这里改为使用JSON数据
        mtype:"POST",
        postData:{  'search_LTE_start':date,'search_GTE_end':date}, //发送数据
        url:'${ctx}/hyglJfjl/query',
        height: '55%',
        footerrow:false,  //合计数据
        colNames:[
        	 '奖励商品名称',   '奖励服务名称',    '需用积分', '开始日期','结束日常', ''],
        colModel:[
					//    {name:'wpid', width:100,sortable:false},
					    {name:'wpmc', width:100,sortable:false},
				//	    {name:'fwlxid', width:100,sortable:false},
					    {name:'fwlxmc', width:100,sortable:false},
					    {name:'xfjf', width:100,sortable:false},
					    {name:'start', width:100,sortable:false},
					    {name:'end', width:100,sortable:false},
            {name:'id',index:'',width:50,sortable:false,hidden:true}
        ],
        rownumbers:true,//添加左侧行号
        sortname: 'id',
        sortable: false,
        viewrecords: true, //是否显示行数
        rowNum:20,
        rowList:[10,20,30],
        loadtext: '正在加载数据...',
        loadui : 'block',
        pager : pager_selector,
        altRows: true,
        shrinkToFit: true,
        //toppager: true,
//
        multiselect: true,
       //multikey: "ctrlKey",
//        multiboxonly: true,

       loadComplete : function() {
            var table = this;
            setTimeout(function(){
                updatePagerIcons(table);
            },
                    0);
        } ,
        ondblClickRow: openview,
//
        caption: "积分奖励管理 <input type='button' onclick='add()'  class='btn btn-mini btn-danger' value='办理兑换'> " ,
        autowidth: true
    });
    


        function  openview(rowid,iRow,iCol,e){
            url = '${ctx}/hyglJfjl/view?id=' + rowid;
            initArtDialog({url:url, title:'查看', width:500, height:280,lock:true,background: '#EAEAEA'});
        }
        
    });

  
  
    
    //replace icons with FontAwesome icons like above
    function updatePagerIcons(table) {
        var replacement =
        {
            'ui-icon-seek-first' : 'icon-double-angle-left bigger-150',
            'ui-icon-seek-prev' : 'icon-angle-left bigger-150',
            'ui-icon-seek-next' : 'icon-angle-right bigger-150',
            'ui-icon-seek-end' : 'icon-double-angle-right bigger-150'
        };
        $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){
            var icon = $(this);
            var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

            if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
        })
    }

    function enableTooltips(table) {
        $('.navtable .ui-pg-button').tooltip({container:'body'});
        $(table).find('.ui-pg-div').tooltip({container:'body'});
    }

    //var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

//    $( "#adds" ).on('click', function(e) {
//        e.preventDefault();
//        addr();
//    });


window.onresize = function  _doResize() {
    var ss = pageSize();
    $("#grid-table").jqGrid('setGridWidth', ss.WinW-10).jqGrid('setGridHeight', ss.WinH-200);
}

function pageSize() {
    var winW, winH;
    if(window.innerHeight) {// all except IE
        winW = window.innerWidth;
        winH = window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {// IE 6 Strict Mode
        winW = document.documentElement.clientWidth;
        winH = document.documentElement.clientHeight;
    } else if (document.body) { // other
        winW = document.body.clientWidth;
        winH = document.body.clientHeight;
    }  // for small pages with total size less then the viewport
    return {WinW:winW, WinH:winH};
}

//select2查询列表每次只查数据的前20条



</script>

</body>
 </@layout> 
